package com.pirestupppai.adapter;

import android.content.Context;
import android.widget.TextView;

import com.pirestupppai.R;
import com.pirestupppai.base.BaseAdapter;
import com.pirestupppai.base.BaseViewHolder;
import com.pirestupppai.bean.TupaiUser;
import com.pirestupppai.utils.ImageLoadUtil;
import com.pirestupppai.widgets.view.AvatarView;
import com.pirestupppai.widgets.view.FollowButton;

import java.util.List;

/**
 * 搜索用户
 *
 * @author: xiaoluo
 * @date: 2017-04-12 16:16
 */
public class SearchUserAdapter extends BaseAdapter<TupaiUser> {
    private Context mContext;
    private List<TupaiUser> mList;

    public SearchUserAdapter(Context context, List<TupaiUser> list) {
        super(list);
        this.mContext = context;
        this.mList = list;
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_search_user;
    }

    @Override
    protected void bindData(BaseViewHolder holder, int position) {
        AvatarView avatar = holder.getView(R.id.search_user_avatar);
        TextView nickname = holder.getView(R.id.search_user_nickname);
        FollowButton followBtn = holder.getView(R.id.follow_btn);

        nickname.setText(mList.get(position).getNickname());
        followBtn.setUser(mList.get(position));
        avatar.setUid(mList.get(position).getId(), false);
        ImageLoadUtil.getInstance().loadAvatar(mList.get(position).getAvatar(), avatar);
    }
}
